package com.am.mosl.cityandroid.util;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

import com.am.mosl.cityandroid.message.LoginMessage;

import de.greenrobot.event.EventBus;

/**
 * Created by mosl on 14-7-10.
 * 对话框帮助类
 */
public class DialogUtil {

    public static final void QuitDialog(final Activity context){

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage("确认注销吗？");
        builder.setTitle("提示");
        builder.setPositiveButton("确认",new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                removeAccount(context);
            }
        });

        builder.setNegativeButton("取消",new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.create().show();
    }

    private static void removeAccount(Context context) {
        SettingUtils.RemoveAccount(context);
        LoginMessage message=new LoginMessage();
        message.setType(LoginMessage.QUIT);
        EventBus.getDefault().post(message);
    }
}
